import React, { useEffect, useState } from 'react';
import { Progress } from 'antd';

const ProgressBar = ({ ifshow,p_title}) => {
  const [progress, setProgress] = useState(0);

  useEffect(() => {
    if(!ifshow){
        setProgress(0);
    }
else{
    const interval = setInterval(() => {
      // 模拟进度增加
      setProgress(prevProgress => (prevProgress < 100 ? prevProgress + 1 : 100));
    }, 200);
    return () => clearInterval(interval);
}
  }, [ifshow]);

  return ifshow ? (
    <div>
      <h3>{p_title}</h3>
      <Progress percent={progress} status="active" />
    </div>
  ) : null;
};

export default ProgressBar;
